package mysqlviewer.model;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JComboBox;
import mysqlviewer.gui.DialogPesan;

/**
 *
 * @author agoesh
 */
public class ModelComboBox{
    private String[] daftarDB;
    
    public ModelComboBox(Connection c, JComboBox j){
        super();
        setDaftarDB(c,j);
    }
    
    public void setDaftarDB(Connection c, JComboBox j){
        try{
            Statement state=c.createStatement();
            ResultSet hasil=state.executeQuery("SHOW DATABASES");
            
            j.removeAllItems();
            while(hasil.next()){
                j.addItem(hasil.getString(1));
            }
        }catch(Exception e){
            new DialogPesan(null, true, e.getMessage());
        }
    }
}
